﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Data;

namespace DataProvider
{
    public class ColumnDataProvider
    {

        public ColumnDataProvider()
        { 
        
        }

        public List<Column> GetColumn(Column row)
        {
            List<Column> retorno = new List<Column>();
            SqlConnection conexao = Connection.GetConnection();

            try
            {
                SqlCommand cmd = new SqlCommand("GetColumn", conexao);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@IdTable", row.IdColumn);
                cmd.Parameters.AddWithValue("@Classe", row.Classe);

                using (SqlDataReader dr = cmd.ExecuteReader())
                {

                    while (dr.Read())
                    {
                        Column temp = new Column();
                        temp.IdColumn = int.Parse(dr["Id"].ToString());
                        temp.Classe = int.Parse(dr["Classe"].ToString());

                        retorno.Add(temp);
                    }
                }

                return retorno;

            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                conexao.Close();
            }
        }


    }
}
